﻿namespace InternetSpiderLib.Scenes.Filters
{
    /// <summary>
    /// 正则场景过滤器
    /// </summary>
    public class RegexSceneFilter : ISceneFilter
    {
        public string Regex { get; set; }

        public string Key { get; set; }


        public bool Filter(DataBox data)
        {
            if (string.IsNullOrEmpty(Key) || Regex == null)
                return false;

            string value = data.Get<string>(Key);
            return System.Text.RegularExpressions.Regex.Match(value, Regex).Success;
        }
    }
}
